home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCUnixInterface.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-06
|
2KB
|
102 lines
/* begincopyright
Copyright (c) 1988 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA
endcopyright */
# include <xr/GC.h>
# include <xr/ThreadsSharedMem.h>
# include <xr/Threads.h>
/*
* Weiser, Demers, Hauser ???
* Boehm, March 9, 1990 12:06:57 pm PST
*/
valloc_free(ptr)
char *ptr;
{
XR_valloc_free(ptr);
}
char *
calloc(a, b)
unsigned int a, b;
{
if ( XR_currThread != NIL ) {
return (char *)GC_malloc(a * b);
} else {
return (char *)XR_AllocSharedSysMem(a*b);
}
}
char *
malloc(a)
unsigned int a;
{
if ( XR_currThread != NIL ) {
/* Should call GC_malloc. But there was a broken client */
/* somewhere in prehistory. */
return (char *)XR_malloc(a);
} else {
return (char *)XR_AllocSharedSysMem(a);
}
}
char *
valloc(a)
unsigned int a;
{
return (char *)XR_valloc(a);
}
char *
realloc(a, b)
char * a;
unsigned int b;
{
if ( a >= GC_heapstart ) {
return (char *)GC_realloc(a,b);
} else {
register char * result;
/* This implementation is pretty bogus, since we dont */
/* know the size of the old block. We claim this */
/* cannot ever read unmapped memory, however, since */
/* the heap follows the system memory area. */
/* Hopefully there are no clients of this anyway. */
result = malloc(b);
if (result == 0) return(0);
bcopy(a, result, b);
return(result);
}
}
void
cfree(x)
char *x;
{
if ( x >= GC_heapstart ) {
XR_free(x);
}
}
void
free(x)
char *x;
{
if ( x >= GC_heapstart ) {
XR_free(x);
}
}